
const baseURL = 'https://bkycms.com/addons/yb_wm/index.php'
// const baseURL = 'http://api_manage.zhycms.com/server/index.php'

import {toast} from '@/utils/toast'
import { mapActions, mapState, mapMutations } from 'vuex';

const request = function(url, method, data,isSys=false) {
 return new Promise((resove,reject)=>{
     var Token =uni.getStorageSync('userinfo');
	 	uni.request({
	 		header: {
	 			'content-type': 'application/x-www-form-urlencoded' ,//自定义请求头信息
	 			// 'content-type': 'application/json' //自定义请求头信息
	 			'storeId':Token.storeId,
	 			'uniacid':Token.uniacid
	 		}, 
	 		dataType:'JSON',
	 		url: baseURL + url,
	 		method,
	 		data,
			success:function(data){
				if(data.statusCode>=500){
					// toast('服务异常,请稍后再试');
				}
				if(data.data.code!=200 && data.data.code!=undefined){
					// toast(data.data.msg);
				}
				if(data.data.code == 225){	
					toast('登录过期请重新登录')
					uni.navigateTo({
					    url: '/pages/auth/login'
					});
				}
				resove(data)
				
			},
	 		fail:function(res){
				console.log(res)
				// reject('服务异常')
	 		// 	toast('服务异常,请稍后再试');
	 			uni.hideLoading();
	 		}
	 	})
	
 })
	 
}


export default request
